<%@ page language="java" pageEncoding="UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <title>洗车工接单</title>
</head>
<body>
<div class="wrap-container">
    <div class="row">
        <div class="col-md-12 col-lg-12">
            <div class="cms-common-content">
                <h3>订单编号：${entity.orderNo}</h3>
                <input type="hidden" id="orderNo" name="orderNo" value="${entity.orderNo}"/>
                <input type="hidden" id="userId" name="userId" value="${entity.userId}"/>
            </div>
            <div class="cms-common-content">
                <h3>洗车工搜索</h3>
                <div class="bltitle-content">
                    <form id="searchForm_">
                        <table class="cms-change-table" cellpadding="0" cellspacing="0">
                            <tbody>
                            <tr>
                                <td class="search-label">手机号码：</td>
                                <td class="search-input">
                                    <input type="hidden" name="search_isValid" class="form-control"  value="1"/>
                                    <input type="text" name="search_phoneNo" class="form-control" placeholder="输入手机号码">
                                </td>
                                <td class="search-label">姓名：</td>
                                <td class="search-input">
                                    <input type="text" name="search_userName" class="form-control" placeholder="输入姓名">
                                </td>
                            </tr>
                            </tbody>
                        </table>
                        <p class="search-actionBtn clearfix">
                            <button type="button" id="search_washer" class="btn btn-primary">查询</button>
                            <button type="reset" class="btn btn-default">重置</button>
                        </p>
                    </form>
                </div> <!--/.bltitle-content-->
            </div><!--/.cms-common-content-->
            <div class="clearfix">
                <table id="user-datatables"
                       class="table table-striped table-bordered table-hover" cellspacing="0" width="100%"></table>
            </div>
        </div>
        <!--/.col-md-12-->
    </div>
    <!--/.row-->
</div>


<script>
    $(function () {
        var rowActionTpl11 = $('#tableActionTpl11').html(); //获取模板引擎

        //jquery datatables
        window.oTableMem  = $('#user-datatables').DataTable({
            'processing': true,
            'serverSide': true,
            'ajax': {
                "url": P.ctx + '/op/washer/datatables.json',
                "type": "POST",
                'data': function (d) {
                    return $.extend({}, d, buildParam_());
                }
            },
            'columns': [
                {'data': 'id', 'title': 'uid', orderable: true},
                {'data': 'createTime', 'title': '注册时间', orderable: true},
                {'data': 'userName', 'title': '姓名', orderable: true},
                {'data': 'sex', 'title': '性别', orderable: true,
                    render: function(data, type, row){
                        if(data == '1'){
                            return P.render("男");
                        }else if(data == '2'){
                            return P.render("女");
                        }
                    }
                },
                {'data': 'phoneNo', 'title': '手机号码', orderable: true},
                {'data': 'idNumber', 'title': '身份证号', orderable: true},
                {'data': 'isValid', 'title': '状态', orderable: true,
                	render: function(data, type, row){
                		if(data == '1'){
                			return P.render("可用");
                		}else if(data == '0'){
                			return P.render("停用");
                		}
                	}
                },
                {'data': 'id', 'title': '操作', width: '10%', orderable: false, class: 'text-left',
                    render: function (data, type, row) {
                        return P.render(rowActionTpl11, row);
                    }
                }
            ],
            'columnDefs': [
                {'defaultContent': '', targets: '_all'}
            ],
            'order': [[2, 'desc']],
            dom: '<"clearfix">rpitip',
            'paginate': true,
            language: {
                sSearch: '<span>搜索:</span> ',
                info: '显示_START_到_END_条,共_TOTAL_条记录',
                infoEmpty: '显示0到0条,共0条记录',
                lengthMenu: '每页_MENU_条',
                processing: '正在处理...',
                emptyTable: '<div class="alert no-margin" style="font-size:12px;padding:5px;">无可用数据</div>',
                zeroRecords: '<div class="alert no-margin" style="font-size:12px;padding:5px;">无记录数据</div>',
                search: '输入搜索',
                paginate: {'first': '首页', 'previous': ' 上一页 ', 'next': ' 下一页 ', 'last': ' 尾页 '}
            }
        });
        //搜索表单
        $('#search_washer').on('click',function(e){
            e.preventDefault();
            oTableMem.ajax.reload( null , true)
        });

        //行：更新按钮 确认接单
        $('#user-datatables').on('click', '[name="affirmReceOrder"]', function (e) {
            e.preventDefault();
            var jsonObj = $(this).data();
            jsonObj.userName = jsonObj.user_name;
            jsonObj.washerId = jsonObj.id;
            jsonObj.orderNo = $('#orderNo').val();
            jsonObj.userId = $('#userId').val();
            jsonObj.orderStatus = "R03";

            if (window.confirm('请再次确认订单('+jsonObj.orderNo +')由洗车工('+jsonObj.userName+')接单？')) {
                $.ajax({
                    url: P.ctx + '/op/order/update',
                    type: 'post',
                    data: jsonObj,
                    success: function (resp) {
                        P.messager({content:resp.msg,type:resp.success==true?'success':'error'}) ;
                        bootbox.hideAll();
                        if(resp.success==true){
                            oTable.ajax.reload( null , true)
                        }
                    }
                });
            }

        });

        function buildParam_() {
            return $.extend($('#searchForm_').serializeObject(), {})
        }

    });//Dom ready
</script>

<!--表格操作列模板定义-->
<script id="tableActionTpl11" type="text/x-mustache">
    <div class="row-actions">
        <span>
            <button type="button" data-id="{{id}}" data-user_name="{{userName}}" class="btn btn-primary" name="affirmReceOrder">确认接单</button>
        </span>
    </div>
</script>


</body>
</html>